package com.sin.java.tool.httpman.model;

import java.util.ArrayList;
import java.util.List;

public class PamInfo extends Node{
	public PamInfo() {
		super(TYPE_PAM);
	}
	private String name;
	private List<String> values = new ArrayList<String>();
	public String getName() {
		return name;
	}
	public List<String> getValues() {
		return values;
	}
	public String getValue() {
		return values.get(0);
	}
	public int getValuesCount(){
		return values.size();
	}
	public PamInfo(String s) {
		this();
		int eqi = s.indexOf('=');
		if(eqi<0){
			throw new IllegalArgumentException(s + "is not valid parameter");
		}
		this.name = s.substring(0, eqi).trim();
		String ss = s.substring(eqi+1);
		String[] vals = ss.split("&");
		for(String val: vals){
			this.values.add(val.trim());
		}
	}
	@Override
	public String toString() {
		return "PamInfo [name=" + name + ", values=" + values + "]";
	}
}
